<template>
  <div id="scroll-board">
    <dv-scroll-board :config="config" ref="scrollBoard" />
  </div>
</template>

<script>
import {
  selectChannelStatistics,
  selectSaleSingle,
  channelSaleTop,
  shopSaleTop,
  selectInventoryData,
  selectInvStatistics,
  getchannelInventoryTop,
  getshopInventoryTop,
  selectFirstStatistics,
  selectAllFirstThreeList,
} from "@/api/chart/SaleDwd";
export default {
  name: "ScrollBoard",
  data() {
    return {
      config: {
        header: ["店铺", "销售金额", "综合退货率", "订单总数"],
        data: [
          //   ["2019-07-01 19:25:00", "路面危害-松散", "5", "xxxxxxx"],
          //   ["2019-07-02 17:25:00", "路面危害-路面油污清理", "13", "xxxxxxx"],
          //   ["2019-07-03 16:25:00", "交安设施-交通标志牌结构", "6", "xxxxxxx"],
          //   ["2019-07-04 15:25:00", "路基危害-防尘网", "2", "xxxxxxx"],
          //   ["2019-07-05 14:25:00", "交安设施-交通标志牌结构", "1", "xxxxxxx"],
          //   ["2019-07-06 13:25:00", "路面危害-松散", "3", "xxxxxxx"],
          //   ["2019-07-07 12:25:00", "路基危害-防尘网", "4", "xxxxxxx"],
          //   ["2019-07-08 11:25:00", "路面危害-路面油污清理", "2", "xxxxxxx"],
          //   ["2019-07-09 10:25:00", "交安设施-交通标志牌结构", "5", "xxxxxxx"],
          //   ["2019-07-10 09:25:00", "路基危害-防尘网", "3", "xxxxxxx"],
        ],
        index: true,
        columnWidth: [50, 180, 100, 100],
        align: ["center"],
        rowNum: 5,
        headerBGC: "#000318",
        headerHeight: 45,
        oddRowBGC: "rgba(0, 44, 81, 0.8)",
        evenRowBGC: "rgba(10, 29, 50, 0.8)",
      },
    };
  },
  mounted() {
    const obj = JSON.parse(localStorage.getItem("result"));
    shopSaleTop(obj).then((response) => {
      console.log(JSON.stringify(response));
      if (response) {
        let shopSaleTopList = [];
        // response ? response : [];
        response.forEach((item) => {
          shopSaleTopList.push([
            item.shop,
            item.salesAmount.toString(),
            item.comprehensiveReturnRate.toFixed(2) + "%",
            item.totalOrdersNumber.toString(),
          ]);
        });
        console.log(JSON.stringify(shopSaleTopList));
        // this.config.data = shopSaleTopList;
        this.$refs["scrollBoard"].updateRows(shopSaleTopList);
        console.log(JSON.stringify(this.config.data));
      }
    });
  },
};
</script>

<style lang="scss">
#scroll-board {
  width: 50%;
  box-sizing: border-box;
  margin-left: 20px;
  height: 100%;
  overflow: hidden;
}
</style>
